package com.agent.web.report;

import com.agent.entity.TblCallSerial;
import com.agent.page.EasyuiPage;
import com.agent.service.ITblCallSerialService;
import com.agent.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.Map;

@RequestMapping(value = "/tblCallSerial")
@Controller
public class TblCallSerialController {

    @Autowired
    ITblCallSerialService tblCallSerialService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody
    public EasyuiPage list(Integer page, Integer rows, TblCallSerial tblCallSerial){
        return tblCallSerialService.list(page,rows,tblCallSerial);
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> insert( TblCallSerial tblCallSerial){
        int id = tblCallSerialService.insert(tblCallSerial);
        Map<String, Object> result = ResponseData.getSuccessResult();
        result.put(ResponseData.DATA,id);
        return result;
    }
    @RequestMapping(value = "/update")
    public Map<String,Object> update( TblCallSerial tblCallSerial){
        // TODO 计算通话时长
        tblCallSerial.setEndTime(new Date());
        tblCallSerialService.update(tblCallSerial);
        return ResponseData.getSuccessResult();
    }

}
